/*
	Copyright (C) 2013 Pontificia Universidad Catolica del Peru
	contact: http://avatar.inf.pucp.edu.pe/realidad-aumentada/
	address contact: Av. Universitaria 1801, San Miguel, Lima-Peru.
	
	This file is part of UbicAR PUCP.

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with This program.  If not, see <http://www.gnu.org/licenses/>.
*/
/*
	Authors: Alvaro Roger Agüero Sánchez, Rodolfo Javier Galvez Meza
	Pontificia Universidad Catolica del Peru
	Departamento de Ingeniería
*/

package org.grupoavatar.guiaubicua.mix.data;

import java.util.ArrayList;

public class Encuesta {
	private int id;
	private String nombre;
	private String detalle;
	private String fIni;
	private String fFin;
	private ArrayList<Pregunta> preguntas;
	private boolean valido;
	private boolean respondido;
	
	public Encuesta(int id, String nombre, String detalle, String fIni, String fFin, ArrayList<Pregunta> preguntas) {
		this.id = id;
		this.nombre = nombre;
		this.detalle = detalle;
		this.fIni = fIni;
		this.fFin = fFin;
		this.preguntas = preguntas;
		this.valido = false;
		this.respondido = false;
	}
	
	public void setRespondido(boolean r) {
		this.respondido = r;
	}
	
	public boolean isRespondido() {
		return this.respondido;
	}
	
	public int getId() {
		return id;
	}

	public String getNombre() {
		return nombre;
	}

	public String getDetalle() {
		return detalle;
	}

	public String getfIni() {
		return fIni;
	}

	public String getfFin() {
		return fFin;
	}

	public ArrayList<Pregunta> getPreguntas() {
		return preguntas;
	}
	
	public boolean isValido() {
		if (valido) {
			return valido;
		} else {
			int contador = 0;
			for (int i = 0; i < preguntas.size(); i++) {
				if (preguntas.get(i).isRespondido())
					contador++;
			}
			if (contador < preguntas.size())
				return false;
			else
				return valido = true;
		}
	}
}
